package com.java110.mall.shop.smo.impl;


import com.java110.intf.shop.IConvenienceMenusInnerServiceSMO;
import com.java110.po.convenienceMenus.ConvenienceMenusPo;
import com.java110.mall.shop.dao.IConvenienceMenusServiceDao;
import com.java110.dto.convenienceMenus.ConvenienceMenusDto;
import com.java110.utils.util.BeanConvertUtil;
import com.java110.core.base.smo.BaseServiceSMO;
import com.java110.dto.user.UserDto;
import com.java110.dto.PageDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName FloorInnerServiceSMOImpl
 * @Description 便民菜单管理内部服务实现类
 * @Author wuxw
 * @Date 2019/4/24 9:20
 * @Version 1.0
 * add by wuxw 2019/4/24
 **/
@RestController
public class ConvenienceMenusInnerServiceSMOImpl extends BaseServiceSMO implements IConvenienceMenusInnerServiceSMO {

    @Autowired
    private IConvenienceMenusServiceDao convenienceMenusServiceDaoImpl;


    @Override
    public int saveConvenienceMenus(@RequestBody ConvenienceMenusPo convenienceMenusPo) {
        int saveFlag = 1;
        convenienceMenusServiceDaoImpl.saveConvenienceMenusInfo(BeanConvertUtil.beanCovertMap(convenienceMenusPo));
        return saveFlag;
    }

     @Override
    public int updateConvenienceMenus(@RequestBody  ConvenienceMenusPo convenienceMenusPo) {
        int saveFlag = 1;
         convenienceMenusServiceDaoImpl.updateConvenienceMenusInfo(BeanConvertUtil.beanCovertMap(convenienceMenusPo));
        return saveFlag;
    }

     @Override
    public int deleteConvenienceMenus(@RequestBody  ConvenienceMenusPo convenienceMenusPo) {
        int saveFlag = 1;
        convenienceMenusPo.setStatusCd("1");
        convenienceMenusServiceDaoImpl.updateConvenienceMenusInfo(BeanConvertUtil.beanCovertMap(convenienceMenusPo));
        return saveFlag;
    }

    @Override
    public List<ConvenienceMenusDto> queryConvenienceMenuss(@RequestBody  ConvenienceMenusDto convenienceMenusDto) {

        //校验是否传了 分页信息

        int page = convenienceMenusDto.getPage();

        if (page != PageDto.DEFAULT_PAGE) {
            convenienceMenusDto.setPage((page - 1) * convenienceMenusDto.getRow());
        }

        List<ConvenienceMenusDto> convenienceMenuss = BeanConvertUtil.covertBeanList(convenienceMenusServiceDaoImpl.getConvenienceMenusInfo(BeanConvertUtil.beanCovertMap(convenienceMenusDto)), ConvenienceMenusDto.class);

        return convenienceMenuss;
    }


    @Override
    public int queryConvenienceMenussCount(@RequestBody ConvenienceMenusDto convenienceMenusDto) {
        return convenienceMenusServiceDaoImpl.queryConvenienceMenussCount(BeanConvertUtil.beanCovertMap(convenienceMenusDto));    }

    public IConvenienceMenusServiceDao getConvenienceMenusServiceDaoImpl() {
        return convenienceMenusServiceDaoImpl;
    }

    public void setConvenienceMenusServiceDaoImpl(IConvenienceMenusServiceDao convenienceMenusServiceDaoImpl) {
        this.convenienceMenusServiceDaoImpl = convenienceMenusServiceDaoImpl;
    }
}
